if(!$){
	alert('iframe need jquery');
}

if(!parent.$){
	alert('parent need jquery');
}

if(!this.r929){
	this.r929	=	{};
}

(function(){
	
	var divi	=	{};
	
	divi.notice	=	function(token, data){
		if(divi.notice.searchTarget["notice_"+token] && typeof(divi.notice.searchTarget["notice_"+token]) == "function"){
			divi.notice.searchTarget["notice_"+token](data);
		}
	};
	divi.notice.searchTarget	=	window;
	
	divi.destroy	=	function(){
		if(window){
			if(window["destroy"] && typeof(window["destroy"] == "function")){
				window.destroy();
			}
			delete window.r929.divi.iframeBody;
			delete window.i$;
			delete window.p$;
			delete window.jQuery;
			delete window.r929.divi;
		}
	};
	
	divi.broadcast	=	function(token, data){
		if(parent && parent!=window){
			parent.r929.divi.broadcast(token, data);
		}
	};
	
	this.r929.divi	=	divi;
	
	this.broadcast	=	divi.broadcast;
})();


var i$	=	null;
var p$	=	null;

$().ready(function(){
	if(parent && parent!=window){
		if(window.location.hash){
			r929.divi.iframeId	=	window.location.hash.split('#')[1];
			r929.divi.ii	=	r929.divi.iframeId+'_';
		}else{
			r929.divi.iframeId	=	"";
			r929.divi.ii	=	"";
		}
		
		$('[id]').each(function(){
			$(this).attr('id', r929.divi.ii+$(this).attr('id'));
		});
		
		r929.divi.iframeBody	=	$('#'+r929.divi.ii+'iframeBody');
		r929.divi.iframeBody	=	$('<div></div>').append(r929.divi.iframeBody.clone()).html();
		
		i$	=	window.$;
		p$	=	parent.$;

		r929.divi.iframeBody	=	p$(r929.divi.iframeBody);
		r929.divi.ib	=	r929.divi.iframeBody;
		
		window.jQuery	=	function(selector, context){
			if(typeof(selector)=='string' && selector.substring(0,1)!='<'){
				selector	=	selector.replace(/#/g, '#'+r929.divi.ii);
			}
			return p$(selector, context || r929.divi.iframeBody);
		};
		for(p in p$){
			window.jQuery[p]	=	p$[p];
		}
		window.$	=	window.jQuery;
		
		init();
		
		parent.r929.divi.iframeReady(r929.divi.iframeId, r929.divi.iframeBody, window);
	}else{
		r929.divi.iframeId	=	"";
		r929.divi.ii	=	"";
		r929.divi.iframeBody	=	$('#iframeBody');
		r929.divi.ib	=	r929.divi.iframeBody;
		i$	=	window.$;
		p$	=	window.$;
		init();
	}
});